package com.lujianfei.powersearch.ui.createOrUpdate.widget.imageviewedit.adapter.viewholder

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.lujianfei.powersearch.databinding.ImageviewEditItemBinding
import com.lujianfei.powersearch.ui.createOrUpdate.widget.imageviewedit.model.ImageViewEditItem

class ImageViewEditAdapterViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

    private var binding: ImageviewEditItemBinding?= null

    init {
        binding = ImageviewEditItemBinding.bind(itemView)
    }

    fun bind(image: ImageViewEditItem, onRemoveClick:(ImageViewEditItem)->Unit) {
        binding?.onRemoveClick = View.OnClickListener {
            onRemoveClick.invoke(image)
        }
        binding?.showPlay = image.imageUri.toString().contains("video")
        binding?.model = image
    }

    fun canMove():Boolean {
        return binding?.model?.type == ImageViewEditItem.TYPE_NORMAL
    }
}